﻿using LanguagePolish.EntityModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LanguagePolish.Controls
{
    public class MonthCalendarModel
    {
        /// <summary>
        /// Текущий месяц
        /// </summary>
        public int CurrentMonth { get; set; }

        /// <summary>
        /// Текущий год
        /// </summary>
        public int CurrentYear { get; set; }

        /// <summary>
        /// Инициализирует новый экземпляр <see cref="CalendarModel"/> для текущей даты.
        /// </summary>
        public MonthCalendarModel()
        { 
            DateTime now = DateTime.Now;
            CurrentMonth = now.Month;
            CurrentYear = now.Year;
        }

        public void IncrementMonth()
        {
            DateTime dt = new DateTime(CurrentYear, CurrentMonth, 1);
            dt = dt.AddMonths(1);
            CurrentMonth = dt.Month;
            CurrentYear = dt.Year;
        }

        public void DecrementMonth()
        {
            DateTime dt = new DateTime(CurrentYear, CurrentMonth, 1);
            dt = dt.AddMonths(-1);
            CurrentMonth = dt.Month;
            CurrentYear = dt.Year;
        }

        // снести
        public IEnumerable<Lesson> GetLessons(DateTime from, DateTime to)
        {
            var context = LinksProvider.Model.EntityContext;
            return context.Lessons.Where(s => s.LessonDate >= from && s.LessonDate <= to).ToList();
        }
    }
}
